/********************* COPYRIGHT  **********************
* File Name        : if_port.c
* Author           : Levetop Electronics
* Version          : V1.0
* Date             : 2017-9-11
* Description      : 不同的驱动接口
********************************************************/


// #include "usart.h"
#include "if_port.hpp"
using namespace hal;
// ------------------------------------------------------------ SPI驱动 --------------------------------------------------------------------
void SPI_CmdWrite(uint8_t cmd)
{
	spi2::cs_low();
	spi2::send_byte(0x00);
	spi2::send_byte(cmd);
	spi2::cs_high();
}

void SPI_DataWrite(uint8_t data)
{
	spi2::cs_low();
	spi2::send_byte(0x80);
	spi2::send_byte(data);
	spi2::cs_high();
}


void SPI_DataWrite_Pixel(uint16_t data)
{
	spi2::cs_low();
	spi2::send_byte(0x80);
	spi2::send_byte(data);
	spi2::cs_high();
	
	spi2::cs_low();
	spi2::send_byte(0x80);
	spi2::send_byte(data>>8);
	spi2::cs_high();
}


uint8_t SPI_StatusRead()
{
	uint8_t temp = 0;
	spi2::cs_low();
	spi2::send_byte(0x40);
	spi2::receive_byte(temp);
	spi2::cs_high();
	return temp;
}

uint16_t SPI_DataRead()
{
	uint8_t temp = 0;
	spi2::cs_low();
	spi2::send_byte(0xC0);
	spi2::receive_byte(temp);
	spi2::cs_high();
	return temp;
}





//-----------------------------------------------------------------------------------------------------------------------------------

void LCD_CmdWrite(uint8_t cmd)
{

	SPI_CmdWrite(cmd);

}

void LCD_DataWrite(uint8_t data)
{

	SPI_DataWrite(data);

}

void LCD_DataWrite_Pixel(uint16_t data)
{

	SPI_DataWrite_Pixel(data);

}


uint8_t LCD_StatusRead(void)
{
	uint8_t temp = 0;
	
	temp = SPI_StatusRead();
	
	return temp;
}

uint16_t LCD_DataRead()
{
	uint16_t temp = 0;
	
	temp = SPI_DataRead();
	
	return temp;
}
	  
	 
















